package com.enjoyor.health.HGPT.core.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.enjoyor.health.HGPT.core.entity.UserInfoMiniapp;
import com.enjoyor.health.HGPT.core.entity.UserInfoMiniappSession;
import com.enjoyor.health.HGPT.core.mapper.UserInfoMiniappSessionMapper;
import com.enjoyor.health.HGPT.core.service.IUserInfoMiniappSessionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Maps;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 小程序用户session表 服务实现类
 * </p>
 *
 * @author enjoyor
 * @since 2023-10-18
 */
@Service
public class UserInfoMiniappSessionServiceImpl extends ServiceImpl<UserInfoMiniappSessionMapper, UserInfoMiniappSession> implements IUserInfoMiniappSessionService {

    @Override
    public UserInfoMiniappSession getByOpenId(String openId) {
        QueryWrapper<UserInfoMiniappSession> queryWrapper = Wrappers.query();
        queryWrapper.eq("open_id", openId);
        queryWrapper.orderByDesc("effective_time");
        queryWrapper.last("LIMIT 1");
        return baseMapper.selectOne(queryWrapper);
    }


}
